package tests;

import org.apache.http.entity.ContentType;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.entity.mime.content.StringBody;
import qq2564874169.tuaotuao.fx.io.StringReader;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

public class Run {
    public static void main(String[] args) throws IOException {
        //var file = new FileInputStream("C:\\Users\\aochulai\\Desktop\\微信图片_20240204161252.jpg");
        var httpEntity = MultipartEntityBuilder.create()
                .addPart("name", new StringBody("SpringBoot中文社区", ContentType.APPLICATION_FORM_URLENCODED))
                // JSON数据
                .addPart("info", new StringBody("{\"site\": \"https://springboot.io\", \"now\": 2021}", ContentType.APPLICATION_JSON))
                // 文件数据
                //.addBinaryBody("file", new File("D:\\Downloads\\010eeadd47ae799a0792d9580b36bfaf.jpeg"), ContentType.APPLICATION_OCTET_STREAM, "qqqqqq.jpg")
                .build();

        System.out.println(StringReader.readToEnd(httpEntity.getContent()));
    }
}
